<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="4">
            <el-form-item label="订单编号" prop="enCode">
              <el-input v-model="query.enCode" placeholder="客户名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="客户名称" prop="name">
              <el-input v-model="query.name" placeholder="客户名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="校区名称" prop="campusName">
              <el-input v-model="query.campus" placeholder="校区信息" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="收款日期" prop="time">
              <el-date-picker v-model="query.time" type="daterange" value-format="yyyy-MM-dd" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="收款方式" prop="method">
              <el-select v-model="query.method" placeholder="收款方式" clearable>
                <el-option v-for="(item, index) in methodOptions" :key="index" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="收款类别" prop="status">
              <el-select v-model="query.status" placeholder="">
                <el-option v-for="(item, index) in statusOptions" :key="index" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" v-has="'btn_add'" size="mini" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
            <el-button type="text" v-has="'btn_download'" size="mini" icon="el-icon-download" @click="exportData()">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list" @selection-change="handleSelectionChange">
          <el-table-column prop="enCode" label="收款单号" align="center" min-width="110" />
          <el-table-column prop="name" label="客户名称" align="left" min-width="100" />
          <el-table-column prop="area" label="所在区域" align="left" min-width="100" />
          <el-table-column prop="campusName" label="校区名称" align="left" width="300" show-overflow-tooltip />
          <el-table-column prop="brand" label="收款品牌" align="center">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column label="收款方式" prop="method" align="center">
            <template slot-scope="scope">
              {{ scope.row.method | dynamicText(methodOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="amount" label="收款金额" align="right" />
          <el-table-column prop="time" label="收款时间" min-width="120" :formatter="custom.tableDateFormat" align="center" />
          <el-table-column label="收款类型" prop="type" align="center">
            <template slot-scope="scope">
              {{ scope.row.type | dynamicText(typeOptions) }}
            </template>
          </el-table-column>
          <el-table-column label="收款类别" prop="status" align="center">
            <template slot-scope="scope">
              {{ scope.row.status | dynamicText(statusOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="isFinish" label="完款状态">
            <template slot-scope="scope">
              {{ scope.row.isFinish == true ? '已完款' : '未完款' }}
            </template>
          </el-table-column>
          <el-table-column label="招商经理" prop="manageName" align="left"></el-table-column>
          <el-table-column label="操作" fixed="right" width="180">
            <template slot-scope="scope">
              <el-button type="text" size="mini" v-has="'btn_print'" @click="handlePrint(scope.row.id, scope.row)" class="cu-table-refund">打印预览</el-button>
              <el-button type="text" size="mini" v-has="'btn_edit'" @click="addOrUpdateHandle(scope.row.id, null, true)">编辑</el-button>
              <el-button type="text" size="mini" v-has="'btn_remove'" @click="handleDel(scope.row.id)" class="cu-table-delBtn">删除</el-button>
              <el-button type="text" size="mini" v-has="'btn_refund'" @click="handleRefunds(scope.row.id, scope.row)" class="cu-table-delBtn">退款</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
    <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
    <RefundsForm v-if="refundsFormVisible" ref="refundsForm" @refresh="refresh" />
    <FormPrint v-if="printFormVisible" ref="PrintForm" @refresh="refresh" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
